<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            display: none;
            position: relative;
            margin: 100px auto;
            width: 300px;
            height: 200px;
            border-left: 1px solid red;
            border-bottom: 1px solid red;
        }

        .son {
            position: absolute;
            width: 30px;
            background-color: pink;
            bottom: 0;
        }

        h4 {
            position: absolute;
            bottom: 0;
            margin-bottom: -20px;
            font-size: 8px;
        }

        span {

            position: absolute;
            top: 0;
            left: 5px;
            font-size: 12px;
            margin-top: -20px;
        }

        .son1 {
            height: 125px;
            left: 40px;
        }

        .son2 {
            left: 100px;
            height: 150px;
        }

        .son3 {
            left: 180px;
            height: 100px;
        }

        .son4 {
            left: 255px;
            height: 175px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="son son1">

            <span>125</span>
            <h4>第1季度</h4>
        </div>
        <div class="son son2">

            <span>160</span>
            <h4>第2季度</h4>
        </div>
        <div class="son son3">

            <span>100</span>
            <h4>第3季度</h4>
        </div>
        <div class="son son4">

            <span>210</span>
            <h4>第4季度</h4>
        </div>
    </div>
    <script>
        const son1 = document.querySelector('.son1')
        const son2 = document.querySelector('.son2')
        const son3 = document.querySelector('.son3')
        const son4 = document.querySelector('.son4')
        const box = document.querySelector('.box')
        const span1 = document.querySelector('.son1 span')
        const span2 = document.querySelector('.son2 span')
        const span3 = document.querySelector('.son3 span')
        const span4 = document.querySelector('.son4 span')
        let child1 = +prompt('请输入第1季度的营业额')
        let child2 = +prompt('请输入第2季度的营业额')
        let child3 = +prompt('请输入第3季度的营业额')
        let child4 = +prompt('请输入第4季度的营业额')
        // for (let i = 1; i <= 4; i++) {
        //     var sp = 'span' + i
        //     alert(sp)
        //     var chil = 'child' + i
        //     alert(chil)
        //     sp.innerHTML = chil
        // }
        span1.innerHTML = child1
        span2.innerHTML = child2
        span3.innerHTML = child3
        span4.innerHTML = child4
        son1.style.height = `${child1}px`
        son2.style.height = `${child2}px`
        son3.style.height = `${child3}px`
        son4.style.height = `${child4}px`
        box.style.display = 'block'

    </script>
</body>

</html>